<%@ page pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><fmt:message key="user.common.title"/></title>
<script src="<c:url value='/scripts/common.js'/>"></script>
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
-->
</style>
<link href="./../styles/layout.css" rel="stylesheet" type="text/css" />	
<script>
	var aa = '<c:out value="${testf}"/>';
  	
 	if(null!=aa && ""!=aa) 
 	{
 		alert(aa);
 		document.location = './userList.html?action=userList';
 	}
</script> 	
<script type="text/javascript">
<!--
function killErrors() {
return true;
}
window.onerror = killErrors;

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
//-->
</script>
<script src="<c:url value='/scripts/common.js'/>"></script>
<script src="<c:url value='/scripts/change_region.js'/>"></script>
</head>

<body leftmargin="0" topmargin="0">
<html:form action="/manage/userList.shtml?action=userList" styleId="userInfoBean">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td class="home-content-title">
    <img src="../images/passenger.gif" width="21" height="22" align="absmiddle"/>
     用户管理
    </td>
  </tr>
  <tr> 
    <td height="25" class="home-table-tool-content02">
      <input name="Submit21" type="button" class="home-inputBtn" value='<fmt:message key="common.button.add"/>' onclick="MM_openBrWindow('./userPreInsert.shtml?action=preInsert','','width=680,height=400,scrollbars=yes')" 
      <p:notAllow pid="6321"> 
      	disabled
      </p:notAllow>
      />&nbsp;
  	  <input name="Submit22" type="button" class="home-inputBtn" value='<fmt:message key="common.button.delete"/>' onclick="javascript:delCheck();" 
  	     <p:notAllow pid="6323"> 
      		disabled
      	 </p:notAllow>
  	  />&nbsp;
  	  <input name="Submit23" type="button" class="home-inputBtn" value='导入' onclick="importFile();" 
  	     <p:notAllow pid="6327"> 
      		disabled
      	 </p:notAllow>
  	  />&nbsp;
  	  <input name="Submit24" type="button" class="home-inputBtn" value='禁用' onclick="logout();"
  	     <p:notAllow pid="6328"> 
      		disabled
      	 </p:notAllow>
  	  /> 
    </td>
  </tr>
              	<tr>
                  <td height="23" align="left" valign="top" class="home-search-space">
                  	<table width="100%" border="0" cellspacing="0" cellpadding="0" >
                    <tr> 
                      <td colspan="5" height="8"></td>
                    </tr>
                    <tr id="normalSrch">
                      		<td align="right" width="10%"><fmt:message key="dept.common.name"/>：</td>
                      		<td width="30%">
							 	<input type="text" class="home-table-inputbox" name="deptName" id="selectedText" size="12"  value="<c:out value='${userInfoBean.deptName}'/>"/>
							 	<input type="hidden" name="deptId" id="selectedId" size="12"/>
								<input name="Submit" type="button"  class="home-inputBtn" onclick="MM_openBrWindow('../deptChoose.html','','width=200,height=400,status=yes')" value="<fmt:message key="manager.common.func.select"/>" />
								<input type="button"  class="home-inputBtn" value="清除" onclick="doClear('deptId','deptName')"/>
							</td>
                      		 <td align="right" width="10%">
                      		 	<%--fmt:message key="user.common.enName"/--%>
                      		 	用户帐号：</td>
                      		 <td width="20%">	
                      		 	<html:text property="enName" styleId="enName" size="10" styleClass="home-table-inputbox"/>
                      		 </td>
                         
                          <td  width="30%">
                          	  <input name="Submit11" type="button" class="home-inputBtn" value='<fmt:message key="button.search"/>' onclick="javascript:searchList()"/>&nbsp;
                          	  <input name="Submit12" type="button" class="home-inputBtn" value='<fmt:message key="button.reset"/>' onclick="doReset('enName','cnName','msisdn')"/>&nbsp;
							  <input name="Submit13" type="button" class="home-inputBtn" value='<fmt:message key="common.button.superSrch"/>' onclick="changeSearchStatus()"/>&nbsp;
                          </td>
                   </tr>
                     
                    <tr> 
                      <td colspan="5" height="8"></td>
                    </tr>
                    
                    <tr id="superSrch" style="display:none">
			                <td align="right">角色：</td>
                      		<td> 
							<html:text property="roleName" styleId="roleName" readonly="true"  size="12" styleClass="home-table-inputbox"/>
							<input type="hidden" name="roleId" id="roleId" size="12" value="<c:out value='${userInfoBean.roleId}'/>"/>
							<input name="Submit" type="button"  class="home-inputBtn" onclick="MM_openBrWindow('../roleFuncAction.html?method=choose','','width=700,height=500,status=yes')" value="<fmt:message key="manager.common.func.select"/>" />
							<input type="button" value="清除" class="home-inputBtn" onclick="doClear('roleId','roleName')"/>
							</td>
							<td align="right"><fmt:message key="user.common.cnName"/>：</td>
                      		<td> 
							<html:text property="cnName" styleId="cnName" size="10" styleClass="home-table-inputbox"/></td>
							<td>&nbsp;</td>
                      	
                     </tr>
                    <tr> 
                      <td colspan="5" height="8"></td>
                    </tr>
                     <tr id="superSrch1" style="display:none">
	                     <td  align="right">
							<fmt:message key="manager.common.func.isUsable"/>：</td>
						 <td>	
							<html:radio property="isUsable" value="0" />
									是
                            <html:radio property="isUsable" value="1" />
									否	
						</td>
						<td  align="right"><fmt:message key="user.common.msisdn"/>：</td>
						<td><html:text property="msisdn"  styleId="msisdn" size="15" maxlength="12" styleClass="home-table-inputbox"/> 	
						</td>
						
						<td>&nbsp; </td>
					</tr>
						
                     <tr> 
                      <td colspan="5" height="8"></td>
                    </tr>  	
                  </table>
                </td>
                     
   </tr>

   <tr> 
    <td valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr> 
          <td class="home-table-topline"> </td>
        </tr>
        <tr> 
          <td class="home-table-leftline"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td class="home-table-tool-content02">
                <sasis:page items="${userList}"/>
                </td>
              </tr>
              <tr> 
                <td align="center" valign="top" class="home-edittable-space">	
		<table width="100%" border="0" cellpadding="2" cellspacing="0" class="list_bordercolor">
                    <tr> 
                      <td width="4%" height="26" class="home-list-title"><input type='checkbox' name='selectAll'  
		            onclick='checkAll(this.checked);'/></td>
                      <td width="5%" class="home-list-title"><fmt:message key="messageLogForm.sort"/></td>
                      <td width="15%" class="home-list-title"><fmt:message key="user.common.department"/></td>
                      <td width="21%" class="home-list-title"><%--fmt:message key="user.common.enName"/--%>用户帐号</td>
                      <td  class="home-list-title"><fmt:message key="user.common.cnName"/></td>
                      <td  width="8%" class="home-list-title"><fmt:message key="user.common.isUsable"/></td>
                     <p:allow pid="6324"> 
                      <td width="6%" class="home-list-title"> <fmt:message key="provisionForm.view" /></td>
                     </p:allow> 
                      <p:allow pid="6322">
                      <td width="6%" class="home-list-title"> <fmt:message key="common.button.update" /></td>
                      </p:allow>
                      <p:allow pid="6326">
                      <td width="6%" class="home-list-title"> 授权</td>
                      </p:allow>
                    </tr>
                    
                    <c:forEach var="results" items="${userList}"  varStatus="status">
                    <tr>
                      <td height="26" class="home-list-content"> <input type="checkbox" name="id"  value="<c:out value='${results.id}'/>"/></td>
                      <td class="home-list-content">&nbsp;<c:out value="${status.count}"/></td>
                      <td class="home-list-content">&nbsp;<c:out value="${results.deptName}"/></td>
                      <td class="home-list-content">&nbsp;<c:out value="${results.enName}"/></td>
                      <td align="center" class="home-list-content">&nbsp;<c:out value="${results.cnName}"/></td>
                      <td align="center" class="home-list-content">&nbsp;
                      	<c:choose>
					 		<c:when test="${results.isUsable == 0}">
					 			<fmt:message key="runtimepatternForm.isnotice.1"/>
					 		</c:when>
					 		<c:otherwise>  
					 			<fmt:message key="runtimepatternForm.isnotice.0"/>
					        	
					        </c:otherwise>
				        </c:choose>	
                      	
                      </td>
                     <td align="center" class="home-list-content">
                      <p:allow pid="6324">
	                     <img src="../images/view.gif" width="14" height="14" 
						 onclick="javascript:edit('<c:out value="${results.enName}"/>','view')"
							alt="<fmt:message key="provisionForm.view" />" style="cursor:hand">
						</p:allow>
					</td>  
				 <td align="center" class="home-list-content">
				  <p:allow pid="6322">
					 <img src="../images/edit.gif" width="14" height="14" style="cursor:hand" 
					alt="<fmt:message key="common.button.update" />" 
					onclick="javascript:edit('<c:out value="${results.enName}"/>','')"
					> 
				</p:allow>
				</td>
				<p:allow pid="6326">
				<td align="center" class="home-list-content">
				
				<img src="../images/role.gif" style="cursor:hand" 
				alt="<fmt:message key="user.role.set.label" />"
				onclick="javascript:(1 < document.forms[0].id.length)?selected(document.forms[0],'./userRoleSet.shtml?action=userRoleSet',document.forms[0].id[<c:out value="${status.count}"/>-1].value,'<c:out value="${results.enName}"/>'):selected(document.forms[0],'./userRoleSet.shtml?action=userRoleSet',document.forms[0].id.value,'<c:out value="${results.enName}"/>');"
				> 
			
				</td>
				</p:allow>
                    </tr>
                    </c:forEach>
                    
                  </table>
                  
                </td>
              </tr>
            </table></td>
        </tr>
        <tr> 
          <td height="12"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td class="home-table-bottom-left">&nbsp;</td>
                <td class="home-table-bottom-bg">&nbsp;</td>
                <td class="home-table-bottom-right">&nbsp;</td>
              </tr>
            </table></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td height="10">&nbsp;</td>
  </tr>
</table>

<html:hidden property="aryId"/> 
<html:hidden property="seledId"/> 
<html:hidden property="handle"/> 
</html:form>

<script>
	function delCheck(){
		
			var ary = submitData();  
		if(ary.length>0){	 
			if(confirm("确定要删除该记录吗?")){	 
				document.forms[0].aryId.value = ary; 
				document.forms[0].action="./userDelete.html?action=delete";
				document.forms[0].submit();
			}else return false;
		}else alert("请选择要删除的记录!");
		 
 	}
 	
 	function logout(){
		
			var ary = submitData();  
		if(ary.length>0){	 
			if(confirm("确定要禁用该记录吗?")){	 
				document.forms[0].aryId.value = ary; 
				formSubmit(document.forms[0],"./userDelete.shtml?action=logout");
			}else return false;
		}else alert("请选择要禁用的记录!");
		 
 	}

	function importFile(){
		var url = "../import.html?action=import";
		MM_openBrWindow(url,'','width=400,height=300');
	}
	 	
 	function edit(enName,target){ 
 		if(target == 'view'){
 		MM_openBrWindow('./userInfoView.shtml?action=userInfo&enName='+enName,'','width=580,height=280')
// 			formSubmit(document.forms[0],"./userInfoView.shtml?action=view&enName="+enName);
 		}else MM_openBrWindow('./userInfo.shtml?action=userInfo&enName='+enName,'','width=680,height=300 scrollbars=yes');
		 
 	}
  
	function submitData(){
		var chk = document.forms[0].id;
		var len = chk.length; 
		var ary = new Array();
		if(len>1){
			for(var i=0;i<len;i++){
				if(chk[i].checked){
					ary.push(chk[i].value);
				}
			}
		}else ary.push(chk.value);
		return ary;
	} 
	
	function selected(_form,_url,ary,userId){
	 
		//_form.seledId.value = ary; 
		//formSubmit(_form,_url); 
		MM_openBrWindow(_url+'&userId='+userId+'&seledId='+ary,'','width=500,height=280');
 	}
 	
 	function shSearch(eltName){
	 
	var elt = document.getElementById(eltName);

	if(elt.style.display=="none"){ 
		elt.style.display = "";
	}else elt.style.display = "none";

	} 
	
	function shSearch(source,target){
	 
	var sourceElt = document.getElementById(source);
	var targetElt = document.getElementById(target);
	var handle = document.forms[0].handle.value;
 	if(handle=="")handle = "source";
		if(handle=="source"){  
			document.forms[0].handle.value="target";
			document.forms[0].submit();
		}else if(handle=="target"){  
			document.forms[0].handle.value="source";
			document.forms[0].submit();
		}else if(handle==""){
			document.forms[0].handle.value="source";
			document.forms[0].submit();
		}
		
	} 
	
	function checkAll(status){
               //alert(status);
               for (var i=0;i < document.forms[0].elements.length; i++){
				var e = document.forms[0].elements[i];
				//alert(e.name);
				if (e.name=="id")
					document.forms[0].elements[i].checked=status;
			}
			
		}
		
 	function searchList(){ 
	 	//var e = document.getElementById('superSrch'); 
		var type = document.forms[0].handle.value;
		var param1 = "";
		if(""!=type){
			param1 = "&srchType="+type;
		}
 		
 	var propertyArray = new Array();	
 	propertyArray.push("selectedText");
	propertyArray.push("enName");
	propertyArray.push("msisdn");
	propertyArray.push("cnName");
	propertyArray.push("roleName");
	//alert(propertyArray.length)
	//把验证数组传入验证特殊字符函数
	var result=checkSpecialInput(propertyArray);
	//alert("result="+result);
	if(result==true||result==null){
	     //alert(result);
	   document.forms[0].action="./userList.shtml?action=userList&target=search"+param1;
 		document.forms[0].submit(); 
	     
	}else{
	    alert(result);
	}
 	
 	}
 	
 	function showType(){
		var e = document.getElementById('superSrch'); 
		var e1 = document.getElementById('superSrch1');
		var type = <%=request.getParameter("srchType")%>;
		if(type==0){
			e.style.display = '';
			e1.style.display = '';			
		}else {
			e.style.display = 'none';
			e1.style.display = 'none';			
		}	
 	}
 	//auto search 
 	showType();
 	
 	function resetForm(){
        userInfoBean.reset();
    }
    function changeSearchStatus(){
		var elt = document.getElementById('superSrch');
		var elt1 = document.getElementById('superSrch1');
		
		if(elt.style.display=="none"){ 
			elt.style.display = "";
			elt1.style.display = "";
			document.forms[0].handle.value=0;
		}else {
			elt.style.display = "none";
			elt1.style.display = "none";
			document.forms[0].handle.value=1;			
		}	
	}
	
	function doClear(t1,t2){
		document.getElementById(t1).value="";
		document.getElementById(t2).value="";
	}
	function doReset(t1,t2,t3){
		document.getElementById(t1).value="";
		document.getElementById(t2).value="";
		document.getElementById(t3).value="";
	}
	


</script>

</body>
</html>
